package com.exchange.Public;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Handler;
import android.os.Message;
import android.widget.RemoteViews;
import com.exchange.View.a.b;
import java.io.File;

class i extends Handler
{
  public void handleMessage(Message paramMessage)
  {
    String str1;
    try
    {
      str1 = (String)paramMessage.obj;
      DownloadingService.a(DownloadingService.a.e(this.a)).cancel(DownloadingService.a.a(this.a));
      DownloadingService.a.b(this.a).tickerText = DownloadingService.a.c(this.a) + " 下载完成，请点击安装";
      DownloadingService.a.b(this.a).icon = 17301634;
      DownloadingService.a.b(this.a).contentView.setImageViewResource(b.s(DownloadingService.a.d(this.a)), 17301634);
      DownloadingService.a.b(this.a).contentView.setTextViewText(b.F(DownloadingService.a.d(this.a)), DownloadingService.a.c(this.a) + " 下载完成，请点击安装。");
      DownloadingService.a.b(this.a).contentView.setProgressBar(b.G(DownloadingService.a.d(this.a)), 100, 100, false);
      DownloadingService.a.b(this.a).contentView.setTextViewText(b.H(DownloadingService.a.d(this.a)), "100%");
      DownloadingService.a.b(this.a).flags = 16;
      Intent localIntent1 = new Intent("android.intent.action.VIEW");
      localIntent1.addFlags(268435456);
      localIntent1.setDataAndType(Uri.fromFile(new File(str1)), "application/vnd.android.package-archive");
      DownloadingService.a.b(this.a).contentIntent = PendingIntent.getActivity(DownloadingService.a.d(this.a), 0, localIntent1, 134217728);
      DownloadingService.a(DownloadingService.a.e(this.a)).notify(DownloadingService.a.a(this.a), DownloadingService.a.b(this.a));
      boolean bool = DownloadingService.a(DownloadingService.a.d(this.a));
      String str2 = ExchangeConstants.LOG_TAG;
      Object[] arrayOfObject1 = new Object[1];
      arrayOfObject1[0] = Boolean.valueOf(bool);
      n.c(str2, String.format("forground = %1$B", arrayOfObject1));
      if (bool)
      {
        DownloadingService.a(DownloadingService.a.e(this.a)).cancel(DownloadingService.a.a(this.a));
        Intent localIntent2 = new Intent("android.intent.action.VIEW");
        localIntent2.addFlags(268435456);
        localIntent2.setDataAndType(Uri.fromFile(new File(str1)), "application/vnd.android.package-archive");
        DownloadingService.a.d(this.a).startActivity(localIntent1);
      }
      String str3 = ExchangeConstants.LOG_TAG;
      Object[] arrayOfObject2 = new Object[2];
      arrayOfObject2[0] = DownloadingService.a.c(this.a);
      arrayOfObject2[1] = str1;
      n.a(str3, String.format("%2$10s downloaded. Saved to: %2$s", arrayOfObject2));
      return;
    }
    catch (Exception localException)
    {
      n.b(ExchangeConstants.LOG_TAG, "can not install. " + localException.getMessage());
      DownloadingService.a(DownloadingService.a.e(this.a)).cancel(DownloadingService.a.a(this.a));
    }
  }
}